#ifndef INTEROPWRITER_H
#define INTEROPWRITER_H

#include <functional>
#include "common/constant.h"
#include "InterOpObject.h"
#include "lists.hxx"
#include "InterOpDocumentInstance.h"
#include "InterOpDocumentReference.h"
#include <SPAIopOutputProductStructure.h>

class SPAIopOutputPSReference;

AMCAX_EXCHANGE_NAMESPACE_BEGIN

namespace InterOp
{

    class Writer
    {
    public:
        Writer();

        void WriterToFile(std::string filePath, const std::vector<std::shared_ptr<InterOpObject>> &exchangeShapes);

        void ConvertObject(const std::vector<std::shared_ptr<InterOpObject>> &exchangeShapes, ENTITY_LIST &entityList);

        void WriterToFile(std::string filePath, ENTITY_LIST entityList);

        void ConvertObject2(const std::shared_ptr<InterOpDocumentReference> &docRootReference, ENTITY_LIST &entityList);

        void WriteToFile2(const std::string& filePath, const std::shared_ptr<InterOpDocumentInstance> &docRootInstance);

        void ExportOutputProductStructure(const std::shared_ptr<InterOpDocumentInstance> &docRootInstance, SPAIopOutputProductStructure& oOutputPS);
        void ExportInstanceToOutputProductStructureRecursion(const std::shared_ptr<InterOpDocumentInstance> &docInstance, 
            SPAIopOutputProductStructure& oOutputPS, SPAIopOutputPSReference& oOutputReference);

    private:
        std::unordered_map<int, SPAIopOutputPSReference*> iIdToOutputPSRef_;
    };

}

AMCAX_EXCHANGE_NAMESPACE_END

#endif